package com.gpio;

import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class TestProduceThread implements Runnable {
	
	private static Logger logger = LogManager.getLogger(TestProduceThread.class);
	
	private Session session;
	private MessageProducer producer;
	private String xmlMsg;
	
	public TestProduceThread(Session session,MessageProducer producer,String xmlMsg) {
		this.producer = producer;
		this.session = session;
		this.xmlMsg = xmlMsg;
	}

	@Override
	public void run() {
		try {
			TextMessage message = session.createTextMessage();
			message.setText(xmlMsg);
			producer.send(message);
			logger.info("======================={}线程{}mq发布消息成功=======================",DateTimeUtil.getCurrentDateTimeStr(),Thread.currentThread().getName());
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

}
